	$(function(){
		$("#login-submit").click(function() {
			
			if (IsInputOk()){
				$('#user-login').submit();
			}else{
				//画面最上部移动
				$('html,body').animate({ scrollTop: $("#content-area") }, 'fast');
			}
			
		
		});
		
	});
	
	function IsInputOk(){
		var result1 = isValidEmailAddress();
		var result2 = passWordCheck();
			
		return result1 && result2;
	}
	
	//email check
	function isValidEmailAddress(){
		
		//上次的信息清空
		$("#msg-for-loginEmail").html("");
		
		var objEmail = $("#loginEmail");
			emailVal = jQuery.trim(objEmail.val());
			
		if (emailVal == ""){
			
			$("#msg-for-loginEmail").html("*E-mail field is required");		
	        return false;
		} 
		if(!emailVal.match(/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/g)){
			
			$("#msg-for-loginEmail").html("*Email format is not valid");		
			return false;
		    }
		else{
		     return true;
		    }
	}
	
	function passWordCheck(){
		//上次的信息清空
		$("#msg-for-password").html("");
		
		var objPassl = $("#loginPassWord");
		var passVal1 = jQuery.trim(objPassl.val());
		
		//空 验证
		if (passVal1 == ""  ){
			$("#msg-for-password").html("*password field is required");		
	        return false;
		} 
		
		// 长度 验证
		if (passVal1.length <6 ){
			
			$("#msg-for-password").html("*Password length is not enough");		
	        return false;
		} 
		return true;
	}